fix(dx-4439): Show human-readable prompts in interactive mode after command correction#2443
fix(dx-4439): Show human-readable prompts in interactive mode after command correction#2443harshithad0703 wants to merge 6 commits intodevelopmentfrom
Conversation
When an invalid command is corrected (e.g. loginasda → login), init had run with the invalid command so context.messageFilePath was never set. Interactive prompts then showed i18n keys (e.g. CLI_AUTH_LOGIN_ENTER_EMAIL_ADDRESS) instead of messages (e.g. Enter your email address). - Add prerun hook init-context-for-command that re-builds context and re-initializes messageHandler/cliux/SDKs when messageFilePath is missing and the actual command id is available (e.g. auth:login). - Register the hook as the first prerun hook so it runs before other prerun logic. Made-with: Cursor
|
@harshithad0703 , pls check with @shafeeqd959 regarding base branch. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
❌ BUILD FAILED - Security checks failed Please review and fix the security vulnerabilities before merging. |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
✅ BUILD PASSED - All security checks passed |
Problem
Interactive prompts after command correction: When an invalid command is corrected (e.g.
csdx loginasda→ "Did you mean login?" → Yes), the CLI shows i18n keys (e.g.CLI_AUTH_LOGIN_ENTER_EMAIL_ADDRESS) instead of user-friendly text (e.g. "Enter your email address").Logout confirmation message: When the user answers No to "Are you sure you want to log out?", the CLI still shows "SUCCESS: You're already logged out", which is incorrect—the user chose not to log out and remains logged in.
Solution
1. Human-readable prompts after command correction
init-context-for-command: Whencontext.messageFilePathis missing and the current command id is available (e.g. after correction), re-buildCsdxContextfor that command and re-initializemessageHandler,cliux, and SDK initiators so the correct plugin message file is loaded.2. Correct message when user cancels logout
CLI_AUTH_LOGOUT_CANCELLED: "Log out cancelled".auth:logout, when the user answers No to the confirmation and is still authenticated, show "Log out cancelled" instead of "You're already logged out". "You're already logged out" is now only shown when the user is actually not authenticated.Testing
Interactive prompts (command correction):
csdx loginasda(ornode bin/run.js loginasdafrompackages/contentstack).Logout cancel:
csdx auth:loginand log in.csdx auth:logout, answer No to the confirmation.csdx whoamito confirm you are still logged in.